package com.trigsoft.applist;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.widget.EditText;

public class NewCatDialog implements OnClickListener
{
	CatDialog cd;
	AlertDialog dialog;
	EditText ed;

	public NewCatDialog(CatDialog cd, Context context)
	{
		this.cd = cd;

		ed = new EditText(context);

		dialog = new AlertDialog.Builder(context).setTitle(R.string.addCat).setPositiveButton(R.string.add, this)
				.setView(ed).create();
	}

	public void show()
	{
		dialog.show();
	}

	public void onClick(DialogInterface arg0, int arg1)
	{
		// TODO Auto-generated method stub
		String cat = ed.getText().toString();
		if (cat != null && cat.length() > 0)
			cd.addCat(cat);
	}

}
